﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;
using System.Collections;
using Sunny.UI;

namespace Ui
{
    public partial class Form6 : UIForm
    {
        public Form6()
        {
            InitializeComponent();
        }
        string row;
        public int lenth=0;
        int click=0;
        private void button1_Click_1(object sender, EventArgs e)
        {
            click++;
            if (click<lenth+1)
            {
                row += textBox1.Text + "%";
                textBox1.Clear();
            }
            else
            {
                File.AppendAllLines(textBox2.Text,new string[] { "$"+row});
            }
        }
        string[] vs2 = new string[10];
        private void button2_Click(object sender, EventArgs e)
        {
            comboBox1.Items.Clear();
            if (openFileDialog1.ShowDialog()==DialogResult.OK)
            {
                textBox2.Text = openFileDialog1.FileName.Trim();
                List<string> list = new List<string>(File.ReadAllLines(openFileDialog1.FileName.Trim()));
                foreach (string line in list)
                {
                    if (line.Substring(0, 1) == "#")
                    {
                        //Console.WriteLine(line);
                        string[] vs = line.Substring(1, line.Length - 2).Split('!');
                        int n = 0;
                        foreach (var item in vs)
                        {
                            lenth++;
                            string[] vs1 = item.Split('@');
                            Console.WriteLine(vs1[1]);
                            comboBox1.Items.Add(vs1[0]);
                            vs2[n] = vs1[1];
                            n += 1;
                        }
                    }
                }
            }
            
            
        }
        private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            label2.Text=vs2[comboBox1.SelectedIndex];
        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
